package com.pt.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.pt.entity.Comment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface CommentMapper extends BaseMapper<Comment> {
    
    /**
     * 增加点赞数
     */
    @Update("UPDATE comment SET likes = likes + 1 WHERE id = #{commentId}")
    void incrementLikeCount(Long commentId);
    
    /**
     * 减少点赞数
     */
    @Update("UPDATE comment SET likes = GREATEST(likes - 1, 0) WHERE id = #{commentId}")
    void decrementLikeCount(Long commentId);
} 